<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>


<input type="hidden" name="id" id="id" value="${productOrder.id}"><%--主订单id--%>


<div class="dialog-warp-ajax content-warp pb50 " id="updateNode">
    <input type="hidden" class="nodeLayerIndex">
    <form id="nodeUpdateform" >
        <table class="dggui-table-info">
            <tbody>
            <tr>
                <th>上个完成节点：</th>
                <td>${productOrder.latestEndNodeName}
                    <fmt:formatDate value="${productOrder.latestEndNodeTime}" pattern="yyyy-MM-dd"/>
                </td>
            </tr>

            <tr>
                <th><span class="required">完成节点：</span></th>
                <td>
                    <select class="dggui-select" name="completenode" onchange="nodeUpdate(this)" id="completenode">
                        <c:forEach var="nodeli" items="${nodelist}" varStatus="status">
                            <option value="${nodeli.id}" data-ids="${nodeli.relationFieldIds}" <c:if test="${nodeId==nodeli.id}">selected</c:if>>${nodeli.name}</option>
                        </c:forEach>
                    </select>
                </td>
            </tr>

            <%--不同的节点展示不同的字段 根据数据库配置而来--%>
            <input type="hidden" value="${productOrder.businessTypeCode}" maxlength="80"
                   id="businessTypeId" name="businessTypeId"/>

            <tr class="poerate-box" data-id="1" style="display: none">
                <th >评估公司：</th>
                <td>
                    <input type="text" name="escrowCompany" id="escrowCompanys" value="" class="dggui-input"/>
                </td>
            </tr>

            <tr class="poerate-box" data-id="2" data-num="true" style="display: none">
                <th >评估价格：</th>
                <td>
                    <input type="text" oninput="calcContractMoneyF(this,12);" maxlength="12" name="appraisalCost" id="appraisalCosts"   class="dggui-input"/>
                    <span class="unit">元</span>
                </td>
            </tr>

            <tr class="poerate-box" data-id="3" style="display: none">
                <th><span class="required">征信（好/差）：</span></th>
                <td>
                    <select class="dggui-select" name="credit" id="credits">
                        <option value="">请选择</option>
                        <option value="好">好</option>
                        <option value="差">差</option>
                    </select>
                    <%--<input type="text" name="credit" id="credits" value="" class="dggui-input"/>--%>
                </td>
            </tr>

            <tr class="poerate-box" oninput="calcContractMoneyF(this);" maxlength="12" data-id="4" data-num="true" style="display: none">
                <th >申请金额：</th>
                <td>
                    <input type="text" name="loanAmounts" oninput="calcContractMoneyF(this,12);" maxlength="12" id="loanAmounts" class="dggui-input"/>
                    <span class="unit">元</span>
                </td>
            </tr>

            <tr class="poerate-box" data-id="5" style="display: none">
                <th >签申请时间：</th>
                <td>
                    <input type="text" readonly name="applicationTime" placeholder="签申请时间" class="dggui-input dggui-input-time Wdate"
                           id="applicationTimes">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="6" style="display: none">
                <th >报审时间：</th>
                <td>
                    <input type="text" readonly name="reportTime" placeholder="报审时间" class="dggui-input dggui-input-time Wdate"
                           id="reportTimes">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="7" style="display: none">
                <th >通过时间：</th>
                <td>
                    <input type="text" readonly name="approveTime" placeholder="审核通过时间" class="dggui-input dggui-input-time Wdate"
                           id="approveTimes">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="8" data-num="true" style="display: none">
                <th><span class="required">通过金额：</span></th>
                <td>
                    <input type="text" oninput="calcContractMoneyF(this);" maxlength="12" name="approveMoney" id="approveMoneys" class="dggui-input"/>
                    <span class="unit">元</span>
                </td>
            </tr>

            <tr class="poerate-box" data-id="9" style="display: none">
                <th><span class="required">结案银行：</span></th>
                <td>
                    <input type="text" name="settlementBank" id="settlementBanks" value="" class="dggui-input"/>
                </td>
            </tr>

            <tr class="poerate-box" data-id="10" style="display: none">
                <th><span class="required">注销时间：</span></th>
                <td>
                    <input type="text" readonly name="advanceFundCancel" placeholder="垫资注销时间" class="dggui-input dggui-input-time Wdate"
                           id="advanceFundCancels">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="11" style="display: none">
                <th><span class="required">办抵押时间：</span></th>
                <td>
                    <input type="text" readonly name="mortgageTime" placeholder="抵押时间" class="dggui-input dggui-input-time Wdate"
                           id="mortgageTimes">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="12" style="display: none">
                <th><span class="required">取他权时间：</span></th>
                <td>
                    <input type="text" readonly name="takeHisTime" placeholder="取他权时间" class="dggui-input dggui-input-time Wdate"
                           id="takeHisTimes">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="13" style="display: none">
                <th><span class="required">放款时间：</span></th>
                <td>
                    <input type="text" readonly name="loanTime" placeholder="放款时间" class="dggui-input dggui-input-time"
                           id="loanTimes">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="14" style="display: none">
                <th><span class="required">放款时长：</span></th>
                <td>
                    <input type="text" maxlength="80" name="loanTimeDay" id="loanTimeDays" class="dggui-input"/>
                </td>
            </tr>

            <tr class="poerate-box" data-id="15" style="display: none">
                <th>还款到期日：</th>
                <td>
                    <input type="text" readonly name="repaymentDate" placeholder="还款到期日期" class="dggui-input dggui-input-time Wdate"
                           id="repaymentDates">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="16" style="display: none">
                <th><span class="required">还款时间：</span></th>
                <td>
                    <select class="select-style mini" name="wayOfLoan" id="wayOfLoan"
                            onchange="changewayOfLoan(this)">
                        <option value="3">先息后本</option>
                        <option value="4">等额等息</option>
                        <option value="5">等额本金</option>
                        <option value="6">等本等息</option>
                        <option value="7">减本减息</option>
                        <option value="8">计划归本</option>
                        <option value="1">分期还款</option>
                        <option value="2">其他</option>
                    </select>
                    <input type="text" readonly name="dateOfLoan" placeholder="还款时间" class="Hdate dggui-input dggui-input-time"
                           id="dateOfLoanHidden">
                    <input type="text" maxlength="80"  placeholder="请输入" name="dateOfLoan" id="qtdateOfLoan" class="dggui-input"/>

                </td>
            </tr>

            <%--<tr class="poerate-box" data-id="17" style="display: none">--%>
                <%--<th class="required">还款计划表：</th>--%>
                <%--<td>--%>
                    <%--<input type="text" name="wayOfLoan" id="wayOfLoan" class="dggui-input"/>--%>
                <%--</td>--%>
            <%--</tr>--%>

            <tr class="poerate-box" oninput="calcContractMoneyF(this);" maxlength="12" data-id="18" data-num="true" style="display: none">
                <th >后台结算金额：</th>
                <td>
                    <input type="text" name="settlementAmount" id="settlementAmounts" class="dggui-input"/>
                    <span class="unit">元</span>
                </td>
            </tr>

            <tr class="poerate-box" data-id="19" data-num="true" style="display: none">
                <th ><span class="required">渠道返点：</span></th>
                <td>
                    <input type="text" oninput="calcContractMoneyF(this);" maxlength="12" name="channelRebates" id="channelRebatess" class="dggui-input"/>
                    <span class="unit">元</span>
                </td>
            </tr>

            <tr class="poerate-box" oninput="calcContractMoneyF(this);" maxlength="12" data-id="20" data-num="true" style="display: none">
                <th >对外返点：</th>
                <td>
                    <input type="text" oninput="calcContractMoneyF(this);" maxlength="12" name="foreignRebates" id="foreignRebatess" class="dggui-input"/>
                    <span class="unit">元</span>
                </td>
            </tr>

            <tr class="poerate-box" oninput="calcContractMoneyF(this);" maxlength="12" data-id="21" data-num="true" style="display: none">
                <th >每期还款金额/月：</th>
                <td>
                    <input type="text" oninput="calcContractMoneyF(this);" maxlength="12" name="installmentRepayment" id="installmentRepayments" class="dggui-input"/>
                    <span class="unit">元</span>
                </td>
            </tr>

            <tr class="poerate-box" data-id="22" style="display: none">
                <th >解除抵押时间：</th>
                <td>
                    <input type="text" readonly name="releaseMortgage" placeholder="解除抵押时间" class="dggui-input dggui-input-time Wdate"
                           id="releaseMortgages">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="23" style="display: none">
                <th >估车：</th>
                <td>
                    <input type="text" name="estimateCat" id="estimateCats" class="dggui-input"/>
                </td>
            </tr>

            <tr class="poerate-box" data-id="24" data-num="true" style="display: none">
                <th><span class="required">放款金额：</span></th>
                <td>
                    <input type="text" oninput="calcContractMoneyF(this);" maxlength="12" name="loanMoney" id="loanMoneys" class="dggui-input"/>
                    <span class="unit">元</span>
                </td>
            </tr>



            <tr id="followTime">
                <th>下次跟进时间：</th>
                <td>
                    <input type="text" readonly name="nextFollowTime" placeholder="下次跟进时间" class="dggui-input dggui-input-time Ndate"
                           id="nextFollowTime">
                    <i class="iconfont icon-rili"></i>
                </td>
            </tr>

            <tr class="poerate-box" data-id="25" style="display: none">
                <th><span class="required">资金用途：</span></th>
                <td>
                    <select class="dggui-select" name="capitalUses" id="capitalUsess">
                        <option value="">请选择</option>
                        <option value="1">消费</option>
                        <option value="2">经营</option>
                    </select>
                </td>
            </tr>

            <tr class="poerate-box" data-id="26" style="display: none">
                <th>产权性质：</th>
                <td>
                    <select class="dggui-select" name="interestType" id="interestType">
                        <option value="">请选择</option>
                        <option value="1">住宅</option>
                        <option value="2">商铺</option>
                        <option value="3">公寓</option>
                    </select>
                </td>
            </tr>

            <tr class="poerate-box" data-id="27" style="display: none">
                <th >地址：</th>
                <td>
                    <input type="text" name="address" id="address" class="dggui-input"/>
                </td>
            </tr>
            <tr class="poerate-box" data-id="28" style="display: none">
                <th>面积：</th>
                <td>
                    <input type="text" name="area" id="area" class="dggui-input"/>
                </td>
            </tr>
            <tr class="poerate-box" data-id="29" style="display: none">
                <th>按揭/全款：</th>
                <td>
                    <select class="dggui-select" name="refundType" id="refundType">
                        <option value="">请选择</option>
                        <option value="1">按揭</option>
                        <option value="2">全款</option>
                    </select>
                </td>
            </tr>

            <tr name="remark" >
                <th><span>备注：</span></th>
                <td>
                    <textarea class="dggui-textarea" rows="3" id="remark" name="remark" placeholder="请填写备注,0-500字" maxlength="500"></textarea>
                </td>
            </tr>

            <tr class="poerate-box " name="upload" style="display: none" data-id="17" >
                <th class="vertical-top">还款计划表：</th>
                <td>
                    <div class="upload-compact">
                        <ul>
                            <div>
                                <input class="dggui-upload-file" type="file" id="annexUpload_payBackPlan" data-fileid="${productOrder.id}" data-customerid="${productOrder.customerId}" data-fileType="sc_product_order-hkjhb" name="file" multiple=""
                                       data-isOne="true" data-multiple="false" removeFile="1" downloadFile="1" magnifyFile="1" loadFile="1">
                            </div>
                            <div class="colleting-file" <c:if test="${user.id eq order.flowUserId}"> isdel="1" </c:if> id = "upload-params-node" data-fileid="${order.id}" data-flag="sc_product_order-hkjhb" data-customerid="${order.customerId}">
                                <c:if test="${user.id eq order.flowUserId}">
                                    <div id="upload-node" class="client-upload"></div>
                                </c:if>
                            </div>
                        </ul>
                    </div>
                </td>
            </tr>

            </tbody>
        </table>

    </form>

</div>
<script src="${rootUrl}/static/js/rzsc/common/files/annex2.js?v=${version}" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">

    $(function () {
        nodeUpdate($("#completenode"));//初始化显示自定义节点

    })

    /*-----------绑定layui日期样式----------------------------------------------------*/
    dggui.use('dggdate', function(){
        var dggdate = dggui.dggdate;

        // lay('.Wdate').each(function(){
        $.each($(".Wdate"),function () {
            dggdate.render({
                elem: this,
                type: 'date',
                trigger: 'click',
            });

        });
        dggdate.render({
            elem: '.Ndate',
            type: 'date',
            trigger: 'click',
            min: 0
        });
        dggdate.render({
            elem: '.Hdate',
            type: 'date',
            trigger: 'click',
            format: 'dd'
        });
        lay('#loanTimes').each(function(){
            dggdate.render({
                elem: this,
                type: 'date',
                trigger: 'click',
                done:function(value, date, endDate){
                    getWordDays(value);
                }
            });
        })


    });
    function getWordDays(time){
        $.ajax({
            url: sysInfo.basePath+"/rzsc/flow/getWorkDays.do",
            dataType:'json',
            data: {productId : '${productOrder.id}',loanTime:time},
            type:'post',
            success:function(data){
                if (data.code == 0) {
                    var num = "";
                    if(!isEmpty(data.data)&&data.data!=0){
                        num = data.data
                    }
                    $("#loanTimeDays").val(num);
                }
            }
        });
    }
    /*-----------显示不同节点----------------------------------------------------*/
    function nodeUpdate(obj) {
        var selected = $(obj).find('option:selected');//获取选中select
        var ids = $(selected).attr("data-ids");//获取节点对应的自定义字段
        var company = $(selected).text();//选中节点名称
        var customizeNode = $(".poerate-box");//获取全部自定义字段

        //如果ids不为空
        if (!isEmpty(ids)) {
            var newids = ids.split(",");

            customizeNode.each(function (i, ele) {
                var id = $(ele).attr("data-id");//自定义字段id
                if (newids.indexOf(id) != -1) {
                    $(ele).show();//显示
                    if(id == '17'){//如果显示上传，隐藏备注
                        $("tr[name='remark']").hide();//隐藏
                    }
                    if(id == '16'){//根据选择框，显示不同的输入框
                        changewayOfLoan("#wayOfLoan");
                    }
                } else {
                    $(ele).find("input").val("");//将所有输入框值设置空字符串
                    $(ele).hide();//隐藏
                    $("tr[name='remark']").show();//显示
                }
            });
        }else{//全部隐藏
            customizeNode.each(function (i, ele) {
                $(ele).find("input").val("");//将所有输入框值设置空字符串
                $(ele).hide();//隐藏
            });
            $("tr[name='remark']").show();//显示
        }

        if(company =='完结' || company =='强制完结'){
            $("#followTime").hide();
        }else{
            $("#followTime").show();
        }
        dggui.dialog.relocation($('.nodeLayerIndex').val());
        // if(company =='放款'){
        //     $("tr[name='upload']").show();//显示
        //     $("tr[name='remark']").hide();//隐藏
        // }else{
        //     $("tr[name='upload']").hide();//隐藏
        //     $("tr[name='remark']").show();//显示
        // }
    }//nodeUpdate end

    /**
     * 根据选择不同返款方式，显示不同输入框
     * @param obj
     */
    function changewayOfLoan(obj) {
        //清空值
        $("#dateOfLoanHidden").val('');//还款日期显示
        $("#qtdateOfLoan").val('');//还款输入框显示
        var wayOfLoan = $(obj).val();
        if (wayOfLoan != 2 && wayOfLoan != 1 && wayOfLoan != 8) {//不等于 其他,分期还款,计划归本
            $("#dateOfLoanHidden").css("display","block");//还款日期显示
            $("#qtdateOfLoan").css("display","none");//还款输入框显示
        } else {
            $("#dateOfLoanHidden").css("display","none");
            $("#qtdateOfLoan").css("display","block");

        }

    }
    upload3("upload-node","upload-params-node");
    initUploadFile("annexUpload_payBackPlan");
</script>




